/*
 * Copyright (c) 2010-present www.walkerljl.org All Rights Reserved.
 * The software source code all copyright belongs to the author, 
 * without permission shall not be any reproduction and transmission.
 */
package org.walkerljl.commons.mail.attach;


import org.walkerljl.commons.mail.EmailAttachment;

import javax.activation.DataSource;
import javax.activation.FileDataSource;
import java.io.File;

/**
 * FileAttachment
 *
 * @author lijunlin
 */
public class FileAttachment extends EmailAttachment {

    protected final File file;

    public FileAttachment(File file, String name, String contentId) {
        super(name, contentId);
        this.file = file;
    }

    /**
     * Returns attached file.
     */
    public File getFile() {
        return file;
    }

    @Override
    public DataSource getDataSource() {
        return new FileDataSource(file);
    }
}
